package com.chb.controller;

import com.chb.annotation.LogAnnotation;
import com.chb.model.entity.Goods;
import com.chb.model.vo.*;
import com.chb.service.GoodsService;
import com.chb.service.InventoryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Date;
import java.util.List;

/**
 * @author ：njh
 * @date ：Created in 2023/10/10 9:49
 * @description：盘点控制类
 * @modified By：
 * @version:
 */
@Controller
@RequestMapping("/inventory")
public class InventoryController {

    @Autowired
    private InventoryService inventoryService;


    /**
     * @param
     * @return Result
     * @create by: njh
     * @description: 检查state值
     * @create time: 2023/10/10 9:50
     */
    @RequestMapping("/checkState")
    @ResponseBody
    public Result checkState() {

        Result result = inventoryService.checkState();
        return result;

    }


    /**
     * @param inventoryVoList
     * @return
     * @create by: njh
     * @description: 添加盘点信息
     * @create time: 2023/10/10 9:50
     */
    @RequestMapping("/addInventory")
    @ResponseBody
    @LogAnnotation(business_type = "添加盘点信息")
    public void addInventory(@RequestBody List<InventoryVo> inventoryVoList) {

        inventoryService.addInventory(inventoryVoList);
    }


    /**
     * @param currentPage
     * @param pageSize
     * @return Result
     * @create by: njh
     * @description: 查询所有的盘点信息
     * @create time: 2023/10/10 16:40
     */
    @RequestMapping("/findAllInventory")
    @ResponseBody
    public Result findAllInventory(Integer currentPage, Integer pageSize) {

        Result result = inventoryService.findAllInventory(currentPage, pageSize);

        return result;
    }


    /**
     * @param currentPage
     * @param pageSize
     * @param invenid     盘点id
     * @return Result
     * @create by: njh
     * @description: 根据盘点id查询盘点的商品信息
     * @create time: 2023/10/11 10:26
     */
    @RequestMapping("/findInventoryGoodsByInventoryID")
    @ResponseBody
    public Result findInventoryGoodsByInventoryID(Integer currentPage, Integer pageSize, Integer invenid) {

        Result result = inventoryService.findInventoryGoodsByInventoryID(currentPage, pageSize, invenid);

        return result;
    }


    /**
     * @param inventoryDataVo
     * @return
     * @create by: njh
     * @description: 审核不通过，更新驳回信息
     * @create time: 2023/10/11 10:26
     */
    @RequestMapping("/addReject")
    @ResponseBody
    @LogAnnotation(business_type = "盘点审核驳回")
    public void addReject(@RequestBody InventoryDataVo inventoryDataVo) {

        inventoryService.addReject(inventoryDataVo);

    }


    /**
     * @param inventoryDataVo
     * @return
     * @create by: njh
     * @description: 审核通过，更新审核信息
     * @create time: 2023/10/11 10:26
     */
    @RequestMapping("/addPass")
    @ResponseBody
    @LogAnnotation(business_type = "盘点审核通过")
    public void addPass(@RequestBody InventoryDataVo inventoryDataVo) {

        inventoryService.addPass(inventoryDataVo);

    }


    /**
     * @param inventoryGoodsVo
     * @return
     * @create by: njh
     * @description: 审核通过，更新审核信息
     * @create time: 2023/10/11 10:26
     */
    @RequestMapping("/updPassCount")
    @ResponseBody
    @LogAnnotation(business_type = "盘点后修改分店的商品数量")
    public void updPassCount(@RequestBody List<InventoryGoodsVo> inventoryGoodsVo) {

        inventoryService.updPassCount(inventoryGoodsVo);

    }


    /**
     * @param currentPage
     * @param pageSize
     * @param startTime   开始时间
     * @param endTime     结束时间
     * @param branchid    分店id
     * @param state       审核状态
     * @return Result
     * @create by: njh
     * @description: 查询所有审核通过的盘点信息
     * @create time: 2023/10/11 16:35
     */
    @RequestMapping("/findAllInventoryOnlyPass")
    @ResponseBody
    public Result findAllInventoryOnlyPass(Integer currentPage, Integer pageSize, String startTime, String endTime, Integer branchid, Integer state) {

        Result result = inventoryService.findAllInventory(currentPage, pageSize, startTime, endTime, branchid, state);

        return result;

    }


    /**
     * @param currentPage
     * @param pageSize
     * @param startTime   开始时间
     * @param endTime     结束时间
     * @param branchid    分店id
     * @param state       审核状态
     * @return Result
     * @create by: njh
     * @description: 根据分店id、时间范围、审核状态查询报损信息
     * @create time: 2023/10/11 16:54
     */
    @RequestMapping("/searchInventoryByBranchId")
    @ResponseBody
    public Result searchInventoryByBranchId(Integer currentPage, Integer pageSize, String startTime, String endTime, Integer branchid, Integer state) {

        Result result = inventoryService.searchInventoryByBranchId(currentPage, pageSize, startTime, endTime, branchid, state);

        return result;

    }


}